package
{
	import com.flesler.actoras.core.Actor;
	import com.flesler.actoras.core.ActorBroker;
	import com.flesler.actoras.core.SimpleActor;
	
	import flash.display.Sprite;
	
	public class Main extends Sprite
	{
		public function Main()
		{
			init();
		}
		
		private function init():void
		{
			var broker:ActorBroker = new ActorBroker();

			var a1:Actor = new A1();
			var a2:Actor = new A2();
			
			broker.register(a1);
			broker.register(a2);
			
			broker.send('a2', 'app', 'start');
		}
	}
}
	import com.flesler.actoras.core.SimpleActor;
	

internal class A1 extends SimpleActor
{
	public function A1()
	{
		super('a1');
	}
	
	override protected function receive(...args):void
	{
		trace(args.join(': '));
		reply('respuesta', 'mucho gusto, yo me llamo ' + name);
	}
}

internal class A2 extends SimpleActor
{
	public function A2()
	{
		super('a2');
	}
	
	override protected function receive(...args):void
	{
		if (args[0] === 'start')
			send('a1', 'saludo', 'hola me llamo ' + name);
		else
			trace(args.join(': '));
	}
}